-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PHPORM-325 Add getViews
and categorize table types
#3327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Laravel has php artisan db:show --views
$views = Schema::getViews(); To follow laravel convention Ill adjust and add getViews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds perfect to me. A few minor comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the corrections.
@jmikola could you also review please.
src/Schema/Builder.php
Outdated
foreach ($db->listCollections() as $collectionInfo) { | ||
$collectionName = $collectionInfo->getName(); | ||
|
||
// Skip system collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The system collections are actual collections. In the case of system.profile
, that might actually be something an application would want to query.
I'm not certain it makes sense to exclude these from all output through the integration.
'schema_qualified_name' => $db->getDatabaseName() . '.' . $collectionName, | ||
'size' => null, | ||
'comment' => null, | ||
'collation' => null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is actually relevant, the information should be available via the options
field for each collection info result. See: listCollections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked in PHPORM-326
'name' => $collectionName, | ||
'schema' => $db->getDatabaseName(), | ||
'schema_qualified_name' => $db->getDatabaseName() . '.' . $collectionName, | ||
'size' => null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is relevant, the information can be provided via $collStats
(MongoDB 6.2+). I'm not sure that'd be worth the overhead to obtain this for all collections/views, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone finds it useful, we can do it, but we'll have to check the impact on performance if there are a lot of collections.
Tracked in PHPORM-326
This is now a simple PR, separating tables(collections in mongodb) and views(standard views). No more segregating SYSTEM collections. For dropAllTables, I followed the recommendation to drop the entire database instead of deleting collections individually. However, this approach may lead to errors, such as "database is in the process of being dropped." While I’m unsure if tthere any production workloads that could affect this, it does cause issues in parallel testing when using the same database—an incorrect setup that should instead use separate databases for each test. |
If the library needs to work around this, it might be sufficient to catch a ServerException and no-op for DatabaseDropPending code 215. I reckon that the original approach to delete collections individually would still be subject to a race condition if a collection was created by another connection between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GromNaN: Let me know if there's anything else for me to review, but I think you can take it from here.
- Group collections based on type for better organization - dropAllTables removes database
getViews
and categorize table types
Thank you @masterbater |
Fix #3320
This fixes
db:show
andmigrate:fresh
for database that has virtual view type collectionsConnection::getViews()
php artisan db:show --views
Checklist